package com.cf.base.comm.base;

import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Build;

import com.cf.base.mvp.base.BaseActivity;
import com.cf.base.mvp.mvp.IPresenter;

import java.util.Locale;

/**
 * @author yangji
 */
public class BaseMvpActivity<P extends IPresenter> extends BaseActivity<P> {

    /**
     * 这里需要做处理
     */
    @Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(initSpLanguage(newBase));
    }

    private Context initSpLanguage(Context context) {
        Resources resource = context.getResources();
        Configuration config = resource.getConfiguration();
        Locale locale = new Locale("zh", "HK");
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            config.setLocale(locale);
        } else {
            config.locale = locale;
        }
        return context.createConfigurationContext(config);
    }
}
